<script setup lang="ts">
import { ref } from 'vue'

// ref获取dom
const imgDom = ref<HTMLImageElement | null>(null)
const btnClick = () => {
  console.log(imgDom.value)
  // imgDom.value!.src = ''
  if (imgDom.value) {
    imgDom.value.src = ''
  }
}
</script>

<template>
  <img ref="imgDom" alt="" />
  <button @click="btnClick">获取imgDom</button>
</template>

<style></style>
